package ${pPackage}.controller;

import  ${pPackage}.vo.resp.RespDataVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import ${pPackage}.vo.${ClassName}VO;
import ${pPackage}.service.${ClassName}Service;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description ${ClassName}Mapper
 * @Author ${author}
 * @Date ${createDate}
 */
@RestController
@RequestMapping("/${projectName}/${ClassName?uncap_first}")
public class ${ClassName}Controller {

    @Resource
    private ${ClassName}Service ${ClassName?uncap_first}Service;

    /**
     * 创建<#if table.comment!="">${table.comment}<#else>${ClassName}</#if>信息
     * @param ${ClassName?uncap_first}VO
     * @return 是否成功
     */
    @PostMapping("/create")
    public ResponseEntity<Boolean> create(@RequestBody ${ClassName}VO ${ClassName?uncap_first}VO){
        return ResponseEntity.ok(${ClassName?uncap_first}Service.create(${ClassName?uncap_first}VO));
    }

    /**
     * 修改<#if table.comment!="">${table.comment}<#else>${ClassName}</#if>信息
     * @param ${ClassName?uncap_first}VO
     * @return 是否成功
     */
    @PutMapping("/update")
    public ResponseEntity<Boolean> updateById(@RequestBody ${ClassName}VO ${ClassName?uncap_first}VO){
        return ResponseEntity.ok(${ClassName?uncap_first}Service.update(${ClassName?uncap_first}VO));
    }

    /**
     * 查询<#if table.comment!="">${table.comment}<#else>${ClassName}</#if>信息
     * @param ${table.primaryKeyExt} 主键
     * @return ${ClassName}详情
     */
    @GetMapping("/getById")
    public ResponseEntity<${ClassName}VO> get${ClassName}InfoById(@RequestParam("${table.primaryKeyExt}") ${table.primaryKeyType} ${table.primaryKeyExt}){
        return ResponseEntity.ok(${ClassName?uncap_first}Service.get${ClassName}InfoById(${table.primaryKeyExt}));
    }

    /**
     * 删除<#if table.comment!="">${table.comment}<#else>${ClassName}</#if>信息
     * @param ${table.primaryKeyExt} 主键
     * @return 是否成功
     */
    @DeleteMapping("/delete")
    public ResponseEntity<Boolean> deleteById(@RequestParam("${table.primaryKeyExt}") ${table.primaryKeyType} ${table.primaryKeyExt}){
        return  ResponseEntity.ok(${ClassName?uncap_first}Service.deleteById(${table.primaryKeyExt}));
    }

    /**
     * 批量删除<#if table.comment!="">${table.comment}<#else>${ClassName}</#if>信息
     * @param ids 主键集合
     * @return 是否成功
     */
    @PostMapping("/deleteIds")
    public ResponseEntity<Boolean> batchDeleteByIds(@RequestBody List<${table.primaryKeyType}> ids){
        return ResponseEntity.ok(${ClassName?uncap_first}Service.batchDeleteByIds(ids));
    }

    /**
     * 获取<#if table.comment!="">${table.comment}<#else>${ClassName}</#if>分页信息
     * @param ${table.primaryKeyExt} 主键
     * @return 是否成功
     */
    @GetMapping("/list${ClassName}")
    public RespDataVO<${ClassName}VO> get${ClassName}PageInfo(@RequestParam("page")Integer page, @RequestParam("limit")Integer limit, @RequestParam(value = "key[id]",required = false)String id) {
        return ${ClassName?uncap_first}Service.get${ClassName}PageInfo(page,limit,id);
    }
}

